package com.jwthhealth_pub.old.physicalfitness.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.common.view.TitleLayout;
import com.jwthhealth_pub.old.common.Address.Address;
import com.jwthhealth_pub.old.common.Address.AddressDao;
import com.jwthhealth_pub.old.common.Constant;
import com.jwthhealth_pub.old.physicalfitness.view.adapter.ChoiceCityAdatper;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/1/16.
 */
public class IndividualChoiceCityActivity extends Activity {
    @BindView(R.id.rb)
    RecyclerView rv;
    @BindView(R.id.title_layout)
    TitleLayout titleLayout;

    private String pid;
    private String name;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choice_city);
        ButterKnife.bind(this);

        Intent intent = getIntent();
        pid = intent.getStringExtra(Constant.INDIVIDUALADDRESSSPID);
        name = intent.getStringExtra(Constant.INDIVIDUALPROVINCENAME);

        initTop();
        initData();
    }

    private void initData() {
        AddressDao dao = AddressDao.getInstance();
        List<Address> citys = dao.getCitys(pid);
//        for (int i=0; i<citys.size(); i++) {
//            String name = citys.get(i).getName();
//            if (name.equals("县") || name.equals("市辖区") || name.equals("省直辖行政单位")) {
//            }
//        }

        rv.setLayoutManager(new LinearLayoutManager(this));
        rv.setAdapter(new ChoiceCityAdatper(this, citys));

    }

    private void initTop() {
        titleLayout.setTitle("选择地区");
        titleLayout.setOnTitleLayoutListener(new TitleLayout.TitleLayoutListener() {
            @Override
            public void leftclick() {
                finish();
            }

            @Override
            public void leftTextClick() {

            }

            @Override
            public void rightclick() {

            }

            @Override
            public void rightTextClick() {

            }
        });
    }
}
